package com.troll.wanandroid.repo

import com.rxlife.coroutine.RxLifeScope
import com.troll.eth.live.Live
import com.troll.wanandroid.model.Question
import com.troll.wanandroid.model.QuestionList
import com.troll.wanandroid.net.Response
import rxhttp.toClass
import rxhttp.wrapper.param.RxHttp

/**
 *
 * @Author:   TangPeng
 * @Time:     6/10/21
 * @Remark:
 */
class QuestionRepo {
    var liveQuestion = Live<MutableList<QuestionList>>()
    var liveError = Live<Boolean>()

    fun question(rxLifeScope: RxLifeScope) {
        rxLifeScope.launch({
            liveQuestion.value = RxHttp.get("/wenda/list/1/json")
                .toClass<Response<Question>>()
                .await().data?.datas
        }, onError = {
            liveError.value = true
        })
    }

}